<?php


class NewsProcessor  extends WeModuleProcessor {
    
	public function respond() {
		$rid = $this->rule_id;
		$main = M('NewsReply')->where(array('rule_id'=>$rid))->order("RAND()")->field('id')->find();;
		if (empty($main['id'])) {
			return array();
		}
		$where['id|parentid'] = $main['id'];
		
		$commends = M('NewsReply')->where($where)->order("parentid ASC, id ASC ")->limit('10')->select();
		$news = array();
		
		foreach($commends as $c) {
			$row = array();
			$row['title'] = $c['title'];
			$row['description'] = $c['description'];
			!empty($c['thumb']) && $row['picurl'] = 'http://'.$_SERVER['HTTP_HOST'].'/'. trim($c['thumb'], '/');
			$row['url'] = empty($c['url']) ? $this->createMobileUrl('New/Index', array('name'=>'Home','id' => $c['id'])) : $c['url'];
			$news[] = $row;
		}
		
		return $this->respNews($news);
        
	}
}